package sesion;

import javax.persistence.EntityManager;
import javax.persistence.Query;

import com.google.appengine.api.datastore.Key;

import entity.Narudzbina;


public class NarudzbinaDaoJpa extends GenericJpaDao<Narudzbina, Key> implements NarudzbinaDao{
	
	public Narudzbina pronadjiNarudzbinu(String serijskiBroj)
	{
		Narudzbina narudzbina=null;
		EntityManager em = null;
	    try {
	        em = emf.createEntityManager();
	        Query query = em.createQuery("select m from " + persistentClass.getSimpleName()+" m where m.serijskiBroj='"+serijskiBroj+"'");
	        narudzbina=(Narudzbina)query.getSingleResult();
	    } catch (Exception ex) {
	        ex.printStackTrace();
	    }
	    finally
	    {
	    	em.close();
	    }
		return narudzbina;
	}
}
